using System;
using bitzhuwei.Compiler;

namespace bitzhuwei.AnsiCFormat {
    /// <summary>
    /// Correspond to the Vn node function_definition in the grammar(AnsiC).
    /// </summary>
    internal partial class Vnfunction_definition : IFullFormat {
        // [207] function_definition = declaration_specifiers declarator declaration_list compound_statement ;
        // [208] function_definition = declaration_specifiers declarator compound_statement ;
        // [209] function_definition = declarator declaration_list compound_statement ;
        // [210] function_definition = declarator compound_statement ;


        private readonly IFullFormat complex;

        private readonly TokenRange _scope;
        public TokenRange Scope => _scope;
        public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
            context.PrintBlanksAnd(this.complex, preConfig, writer);
        }


        // [207] function_definition = declaration_specifiers declarator declaration_list compound_statement ;
        public Vnfunction_definition(Vndeclaration_specifiers r3, Vndeclarator r2, Vndeclaration_list r1, Vncompound_statement r0) {
            this.complex = new complex0(r3, r2, r1, r0);
            this._scope = new TokenRange(r3, r0);
        }
        class complex0 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r3, preConfig, writer);
                context.PrintCommentsBetween(r3, r2, config, writer);
                context.PrintBlanksAnd(r2, config, writer);
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Vndeclaration_specifiers r3;
            public readonly Vndeclarator r2;
            public readonly Vndeclaration_list r1;
            public readonly Vncompound_statement r0;
            public complex0(Vndeclaration_specifiers r3, Vndeclarator r2, Vndeclaration_list r1, Vncompound_statement r0) {
                this.r3 = r3;
                this.r2 = r2;
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r3, r0);
            }
        }

        // [208] function_definition = declaration_specifiers declarator compound_statement ;
        public Vnfunction_definition(Vndeclaration_specifiers r2, Vndeclarator r1, Vncompound_statement r0) {
            this.complex = new complex1(r2, r1, r0);
            this._scope = new TokenRange(r2, r0);
        }
        class complex1 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r2, preConfig, writer);
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Vndeclaration_specifiers r2;
            public readonly Vndeclarator r1;
            public readonly Vncompound_statement r0;
            public complex1(Vndeclaration_specifiers r2, Vndeclarator r1, Vncompound_statement r0) {
                this.r2 = r2;
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r2, r0);
            }
        }

        // [209] function_definition = declarator declaration_list compound_statement ;
        public Vnfunction_definition(Vndeclarator r2, Vndeclaration_list r1, Vncompound_statement r0) {
            this.complex = new complex2(r2, r1, r0);
            this._scope = new TokenRange(r2, r0);
        }
        class complex2 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r2, preConfig, writer);
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Vndeclarator r2;
            public readonly Vndeclaration_list r1;
            public readonly Vncompound_statement r0;
            public complex2(Vndeclarator r2, Vndeclaration_list r1, Vncompound_statement r0) {
                this.r2 = r2;
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r2, r0);
            }
        }

        // [210] function_definition = declarator compound_statement ;
        public Vnfunction_definition(Vndeclarator r1, Vncompound_statement r0) {
            this.complex = new complex3(r1, r0);
            this._scope = new TokenRange(r1, r0);
        }
        class complex3 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r1, preConfig, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Vndeclarator r1;
            public readonly Vncompound_statement r0;
            public complex3(Vndeclarator r1, Vncompound_statement r0) {
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r1, r0);
            }
        }



    }
}
